import com.alibaba.druid.pool.DruidDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

public class DruidConnectionPool {
    private static DataSource dataSource;

    static {
        DruidDataSource ds = new DruidDataSource();
        ds.setUrl("jdbc:mysql://localhost:3306/stu_user?useSSL=false&serverTimezone=UTC");
        ds.setUsername("root");
        ds.setPassword("ran09105019");
        ds.setDriverClassName("com.mysql.cj.jdbc.Driver");
        ds.setInitialSize(5);
        ds.setMaxActive(10);
        ds.setMaxWait(10000);
        // 其他配置...  

        dataSource = ds;
    }

    public static Connection getConnection() throws SQLException {
        return dataSource.getConnection();
    }
}